Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve I2C bus recovery of Interrupted READ cycle #1767

Merged
merged 1 commit into from
Aug 18, 2018

Conversation

stickbreaker
Copy link
Contributor

If the esp32 is reset during a i2c read cycle the slave device may be in control of the SDA line.

If the SDA line is held low, the esp32 cannot issue a START or STOP to recover the bus.

The previous code did not correctly configure the SCL output pin, and it cycled SCL 9 times with SDA Low. Since the slave device was in a READ cycle, it just continued outputting the bits of the current byte. When the ACK/NAK bit space occurred, The low output value of SDA was interpreted as ACK so the slave device continued with the next byte. It never terminated the READ cycle.

This new code will correctly recover from an interrupted READ

If the esp32 is reset during a i2c read cycle the slave device may be in control of the SDA line.  

If the SDA line is held low, the esp32 cannot issue a START or STOP to recover the bus. 

The previous code did not correctly configure the SCL output pin, and it cycled SCL 9 times with SDA Low.  Since the slave device was in a READ cycle, it just continued outputting the bits of the current byte.  When the ACK/NAK bit space occurred, The low output value of SDA was interpreted as ACK so the slave device continued with the next byte.  It never terminated the READ cycle. 

This new code will correctly recover from an interrupted READ
@me-no-dev me-no-dev merged commit 9db207a into espressif:master Aug 18, 2018
@stickbreaker stickbreaker deleted the patch-2 branch August 18, 2018 16:13
Curclamas pushed a commit to Curclamas/arduino-esp32 that referenced this pull request Aug 21, 2018
If the esp32 is reset during a i2c read cycle the slave device may be in control of the SDA line.  

If the SDA line is held low, the esp32 cannot issue a START or STOP to recover the bus. 

The previous code did not correctly configure the SCL output pin, and it cycled SCL 9 times with SDA Low.  Since the slave device was in a READ cycle, it just continued outputting the bits of the current byte.  When the ACK/NAK bit space occurred, The low output value of SDA was interpreted as ACK so the slave device continued with the next byte.  It never terminated the READ cycle. 

This new code will correctly recover from an interrupted READ
@vkurpad
Copy link

vkurpad commented Jul 26, 2021

@stickbreaker I am still running into the issue "Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled." after making a HTTP request and trying to read the MPU data again. I tried it with MQTT and didn't have any luck. It appears to be similar to issue #1352.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants